import requests
import json

def test_qkd_key_manager_system():
    base_url = "http://localhost/api/v1/keys"

    # Test the /status API
    print("Testing /status API...")
    response = requests.get(f"{base_url}/status")
    if response.status_code == 200:
        print("/status API Response:")
        print(json.dumps(response.json(), indent=2))
    else:
        print(f"/status API Error: {response.status_code}")

    # Test the /request_keys API
    print("\nTesting /request_keys API...")
    num_keys = 3
    response = requests.get(f"{base_url}/request_keys?num_keys={num_keys}")
    if response.status_code == 200:
        print("/request_keys API Response:")
        print(json.dumps(response.json(), indent=2))
    else:
        print(f"/request_keys API Error: {response.status_code}")

    # Test the /get_key_with_ids API
    print("\nTesting /get_key_with_ids API...")
    key_ids = ["sample-key-id-1", "sample-key-id-2"]  # Replace with valid key IDs from previous response
    headers = {'Content-Type': 'application/json'}
    response = requests.post(f"{base_url}/get_key_with_ids", data=json.dumps({"key_IDs": key_ids}), headers=headers)
    if response.status_code == 200:
        print("/get_key_with_ids API Response:")
        print(json.dumps(response.json(), indent=2))
    else:
        print(f"/get_key_with_ids API Error: {response.status_code}")

if __name__ == "__main__":
    test_qkd_key_manager_system()
